<script setup lang="ts">
// import useStore from "@/store";
// import router from "@/router";
import * as echarts from "echarts";
import { onMounted } from "vue";
import useStore from "@/store";

const store = useStore();
const loadTimes = (window as any).chrome.loadTimes();
const performance = window.performance;
let c:crucial = {
    ip:store.buryPayload.ip,
    path:store.buryPayload.pageUrl,
    requestTime:loadTimes.requestTime,
    startLoadTime:loadTimes.startLoadTime,
    commitLoadTime:loadTimes.commitLoadTime,
    finishDocumentLoadTime:loadTimes.finishDocumentLoadTime,
    finishLoadTime:loadTimes.finishLoadTime,
    firstPaintTime:loadTimes.firstPaintTime,
    domLoading:new Date().getTime(),
    domComplete:new Date().getTime()
} 

 


//进入到script里组件开始渲染
onMounted(() => {
  // 基于准备好的dom，初始化echarts实例
  var myChart = echarts.init((document as any).getElementById("main-bar"));
  // 绘制图表
  myChart.setOption({
    title: {
      text: "ECharts 入门示例",
    },
    tooltip: {},
    xAxis: {
      data: ["衬衫", "羊毛衫", "雪纺衫", "裤子", "高跟鞋", "袜子"],
    },
    yAxis: {},
    series: [
      {
        name: "销量",
        type: "bar",
        data: [5, 20, 36, 10, 10, 20],
      },
    ],
  });
  //onMounted DOM渲染用户已经可以看到渲染完成的页面
  c.domComplete = new Date().getTime()
  store.pushCrucial(c);
});
</script>

<template>
  <div id="main-bar"></div>
</template>
<style scoped>
#main-bar {
  width: 100%;
  height: 500px;
}
</style>
